#include "yacc_parser/Atom.h"
#include "symbol_table/SymbolBase.h"


Atom::Atom( SymbolBase *pSymbol )
: m_iAtomType(0)
{
	m_oContent.pSymbolBase = pSymbol;
}

Atom::Atom( char c )
: m_iAtomType(1)
{
	m_oContent.c = c;
}
Atom::~Atom(void)
{
}

SymbolBase * Atom::getSymbol( char & outC )
{
	if(m_iAtomType)
	{
		outC = m_oContent.c;
		return NULL;
	}
	return m_oContent.pSymbolBase;
}

std::string Atom::toString()
{
	std::string s;
	if(m_iAtomType)
	{
		s.push_back('\'');
		s.push_back(m_oContent.c);
		s.push_back('\'');
		return s;
	}
	
	s = m_oContent.pSymbolBase->getSymbolName();
	return s;
}
